If your server has its mail relays open, your server might be used to send spam emails. If you're not sure if your relays are open, try both tests below. If your relays are open, you should use the instructions below to close them.
To Manually Test Your Server for Open Relays
From your local machine, run the following command through cmd (Windows®) or SSH (Mac and Linux):
telnet [server IP] 25
helo me
mail from: testfrom@coolexample.com
rcpt to: testrcpt@coolexample.com
Where [server IP]
is your server's IP address.
If your relays are closed, you will receive an error that you cannot connect, similar to the following error:
Trying IP address...
Connected to mail.myserver.com.
Escape character is '^]'.
...
554 : Relay access denied
If you receive any other outputs, your relays are open.
To Perform an Automated Test for Open Relays
- Go to http://mxtoolbox.com/diagnostic.aspx.
- In the Mail Server field, enter your server's IP address.
- Click Test Email Server.
On the page that displays, receiving a message of Failed To Connect in the Results column of the SMTP Connect row means your relays are closed.
If you receive any other outputs, your relays are open.
To Close Open Relays
Click one of the following, based on your control panel:
- Log in to Plesk as admin.
- Click Server, and then click Mail.
- For Relays, select either Closed or Authentication Required.
- Click OK.
Servers using cPanel® have closed relays by default. If you think they might be open, you can close them.
- Connect to your server via SSH.
- Run the following commands:
/scripts/fixrelayd
/etc/rc.d/init.d/antirelayd restart
service exim restart
- Connect to your server via SSH.
- Using a text editor, add the following line to the bottom of
/etc/postfix/main.cf
: smtpd_sender_restrictions = reject_unknown_sender_domain,reject_non_fqdn_sender
- Run the following command:
service postfix restart